package com.situ.thymeleaf.controller;

import com.situ.thymeleaf.pojo.Student;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Controller
public class IndexController {

    @RequestMapping("/index")
    public String index(Model model) {
        model.addAttribute("message", "HelloWorld");

        Student student = new Student(1, "李四", 23, new Date());
        model.addAttribute("student", student);

        Student student1 = new Student(1, "张三1", 23, new Date());
        Student student2 = new Student(2, "张三2", 23, new Date());
        Student student3 = new Student(3, "张三3", 23, new Date());
        List<Student> list = new ArrayList<>();
        list.add(student1);
        list.add(student2);
        list.add(student3);
        model.addAttribute("list", list);

        return "index";
    }
}
